﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameWorkSong;

public class PoolExample : MonoBehaviourSimplify
{
    class Fish { }
    private void Start()
    {
        mian();
    }
    void mian()
    {
        var fishPool = new SimpleObjectPool<Fish>(creatFish, mDestroy, 10);
        Debug.Log(fishPool.CurCount);
        //得到对象
        var fishone = fishPool.Allocate();

        ReleaseMemory();
        Debug.Log(fishPool.CurCount);
        //回收对象
        fishPool.Recycle(fishone);
        Debug.Log(fishPool.CurCount);
    }
    //重置对象
    void mDestroy(Fish obj)
    {
        obj = null;
    }
    //创建对象
    Fish creatFish()
    {
        Fish fish=  new Fish();
        return fish;

    }

    public override void OnBeforeDestroy()
    {
    }
}
